fix(WorkspaceTracker): Dispose FileSystemWatcher and other disposables to prevent resource leaks #4237
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR for WorkspaceTracker FileSystemWatcher Leak (WorkspaceTracker_45)
This PR addresses the
FileSystemWatcherleak in theWorkspaceTrackerclass, as identified inleak-report/guaranteed/WorkspaceTracker_45.md.Description
The
WorkspaceTrackerclass creates aFileSystemWatcherin itsregisterListenersmethod and adds it to adisposablesarray. However, thedispose()method ofWorkspaceTrackercurrently only clears internal timers and does not dispose of the items in thedisposablesarray, including theFileSystemWatcher. This leads to a resource leak when aWorkspaceTrackerinstance is disposed.This patch updates the
dispose()method inWorkspaceTracker.tsto iterate over and dispose of all items in thethis.disposablesarray, ensuring theFileSystemWatcheris properly cleaned up.Related Bug Report
#4236
Changes
src/integrations/workspace/WorkspaceTracker.ts:dispose()method to include:How to Test
WorkspaceTrackerto initialize (e.g., by opening/closing files or tabs, or simply waiting a short period).WorkspaceTrackerinstance. This might involve:WorkspaceTrackeris tied to its lifecycle.dispose()on aWorkspaceTrackerinstance.FileSystemWatchercreated by theWorkspaceTrackeris no longer active.Important
Fixes resource leak in
WorkspaceTrackerby ensuringFileSystemWatcherand other disposables are properly disposed of.WorkspaceTrackerby updatingdispose()method inWorkspaceTracker.tsto dispose of all items inthis.disposablesarray.FileSystemWatcheris properly disposed of, preventing resource leaks.FileSystemWatcheris inactive afterWorkspaceTrackerdisposal by simulating disposal and checking for continued file system monitoring.This description was created by
for 08f92e2. You can customize this summary. It will automatically update as commits are pushed.
Closes: #4236